<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--

    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.

-->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<title>web.xml Visual Editor: Servlets</title>
<link rel="stylesheet" href="ide.css" title="Oracle BLAFDoc" type="text/css"/>
</head>

<body>
<p><a id="dd_multiview_servlets_servletNode" name="dd_multiview_servlets_servletNode"></a></p>
<div id="NBCSH3783"><!-- infolevel="all" infotype="General" --><a id="sthref514" name="sthref514"></a>
<h1>web.xml Visual Editor: Servlets</h1>
<a name="BEGIN" id="BEGIN"></a>
<p>Use the Servlet section of the <code dir="ltr">web.xml</code> Visual Editor to add, remove, and view the deployment information of your web application's servlets and, optionally, JSP files. 
<object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer">
<param name="content" value="http://www.oracle.com/pls/topic/lookup?ctx=nb8200&id=NBDAG1114">
<param name="text" value="<html><u>How?</u></html>">
<param name="textFontSize" value="medium">
<param name="textColor" value="blue">
</object>
</p>
<a id="NBCSH3784" name="NBCSH3784"></a>
<p><b>Servlets</b></p>
<p>Servlets are Java classes that can be loaded dynamically into a server and executed by the server to extend its feature set. Servlets are useful for tasks that involve processing an HTTP request. Servlets are also helpful for tasks that do not generate an HTTP response at all or that generate a relatively simple HTTP response. Servlets use the javax.servlet API.</p>
<p>To deploy a servlet, you must register it in the <code dir="ltr">web.xml</code> file. Doing this provides information needed by the server to deploy the servlet. For example, you tell the server which class should be loaded to deploy the servlet.</p>
<a id="NBCSH3785" name="NBCSH3785"></a>
<p><b>JSP Files</b></p>
<p>JSP technology was designed to simplify the process of creating servlets. In fact, the main function of servlets is to generate HTML output in cases where dynamic portions can be encapsulated. Servlets are generated by JSP pages when compiled. In many applications, the response sent to the client is a combination of template data and dynamically-generated data. In this situation, it is often easier to work with JSP pages than to do everything with servlets.</p>
<p>Unlike servlets, the server automatically deploys JSP files, therefore you do not have to register a JSP files in the <code dir="ltr">web.xml</code> file in order to deploy it. However, if you register a JSP file in the <code dir="ltr">web.xml</code> file, you can use servlet elements to set initialization parameters and mappings for the JSP file, just as if it were a servlet.</p>
<p>Before registering a servlet or JSP file in the <code dir="ltr">web.xml</code> file, you can create the servlet or create the JSP file in the New File wizard, or import it from your existing sources. You can use the Configure Servlet Deployment panel of the New File wizard to register a servlet. If you have not done so, or if you want to modify a registered servlet's deployment information, use the Servlets view of the web.xml Visual Editor. Note that you cannot use the New File wizard to register JSP files.</p>
<p>In the Visual Editor, click <b>Servlets</b> at the top of the editor to open the Servlets view.</p>
<p>First, click <b>Add Servlet Element</b> to define the servlet element with the following properties:</p>

<table summary="User interface elements and descriptions" dir="ltr" border="1" width="100%" frame="hsides" rules="groups" cellpadding="3" cellspacing="0">
<col width="24%" />
<col width="*" />
<thead>
<tr align="left" valign="top">
<th align="left" valign="bottom" id="r1c1-t6">Element</th>
<th align="left" valign="bottom" id="r1c2-t6">Description</th>
</tr>
</thead>
<tbody>
<tr align="left" valign="top">
<td align="left" id="r2c1-t6" headers="r1c1-t6">
<p>Servlet Name</p>
</td>
<td align="left" headers="r2c1-t6 r1c2-t6">Specifies the display name of the servlet or JSP file, such as MyVeryUsefulComponent. 
<object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer">
<param name="content" value="http://www.oracle.com/pls/topic/lookup?ctx=nb8200&id=NBDAG1114">
<param name="text" value="<html><u>How?</u></html>">
<param name="textFontSize" value="medium">
<param name="textColor" value="blue">
</object>
</td>
</tr>
<tr align="left" valign="top">
<td align="left" id="r3c1-t6" headers="r1c1-t6">Description</td>
<td align="left" headers="r3c1-t6 r1c2-t6">Specifies a description, such as <code dir="ltr">Initialization settings for my JSP file</code>.</td>
</tr>
<tr align="left" valign="top">
<td align="left" id="r4c1-t6" headers="r1c1-t6">
<p>&nbsp;&nbsp;&nbsp;&nbsp;Servlet Class</p>
</td>
<td align="left" headers="r4c1-t6 r1c2-t6">Specifies the servlet's class, such as <code dir="ltr">MyVeryUsefulServlet</code>.</td>
</tr>
<tr align="left" valign="top">
<td align="left" id="r5c1-t6" headers="r1c1-t6">
<p>&nbsp;&nbsp;&nbsp;&nbsp;JSP File</p>
</td>
<td align="left" headers="r5c1-t6 r1c2-t6">Specifies the JSP file, such as <code dir="ltr">MyVeryUseFulPage</code>.</td>
</tr>
<tr align="left" valign="top">
<td align="left" id="r6c1-t6" headers="r1c1-t6">
<p>URL Pattern(s)</p>
</td>
<td align="left" headers="r6c1-t6 r1c2-t6">Specifies a mapping between the servlet definition or JSP file definition and a URL pattern, such as <code dir="ltr">/bookstore/*</code>, <code dir="ltr">*.jsp</code>. All requests to the specified URL patterns are handled by the servlet or JSP file associated with the servlet or JSP file definition.</td>
</tr>
</tbody>
</table>
<br />
<!-- -->
<p>When you click <b>OK</b>, the values you entered are displayed in the Servlets section. Optionally, you can now specify the startup order of the servlets in the application. In the Startup Order edit box, type an integer indicating the order in which the servlets should be loaded.</p>
<a id="NBCSH3790" name="NBCSH3790"></a>
<p><b>Initialization Parameters</b></p>
<p>Next, click <b>Add</b> within the servlet element and define its initialization parameters:</p>

<table summary="User interface elements and descriptions" dir="ltr" border="1" width="100%" frame="hsides" rules="groups" cellpadding="3" cellspacing="0">
<col width="24%" />
<col width="*" />
<thead>
<tr align="left" valign="top">
<th align="left" valign="bottom" id="r1c1-t7">Element</th>
<th align="left" valign="bottom" id="r1c2-t7">Description</th>
</tr>
</thead>
<tbody>
<tr align="left" valign="top">
<td align="left" id="r2c1-t7" headers="r1c1-t7">
<p>Param Name</p>
</td>
<td align="left" headers="r2c1-t7 r1c2-t7">Specifies the parameter's display name, such as <code dir="ltr">encoding</code>. 
<object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer">
<param name="content" value="http://www.oracle.com/pls/topic/lookup?ctx=nb8200&id=NBDAG1114">
<param name="text" value="<html><u>How?</u></html>">
<param name="textFontSize" value="medium">
<param name="textColor" value="blue">
</object>
</td>
</tr>
<tr align="left" valign="top">
<td align="left" id="r3c1-t7" headers="r1c1-t7">
<p>Param Value</p>
</td>
<td align="left" headers="r3c1-t7 r1c2-t7">Specifies the parameter's value, such as <code dir="ltr">UTF-8</code>.</td>
</tr>
<tr align="left" valign="top">
<td align="left" id="r4c1-t7" headers="r1c1-t7">
<p>Description</p>
</td>
<td align="left" headers="r4c1-t7 r1c2-t7">Specifies a description, such as <code dir="ltr">Acceptable encoding formats</code>.</td>
</tr>
</tbody>
</table>
<br />
<!-- -->
<a id="NBCSH3794" name="NBCSH3794"></a>
<p><b>Security Role References</b></p>
<p>Optionally, click <b>Add</b> under Security Role References for the servlet to add role references:</p>

<table summary="User interface elements and descriptions" dir="ltr" border="1" width="100%" frame="hsides" rules="groups" cellpadding="3" cellspacing="0">
<col width="24%" />
<col width="*" />
<thead>
<tr align="left" valign="top">
<th align="left" valign="bottom" id="r1c1-t8">Element</th>
<th align="left" valign="bottom" id="r1c2-t8">Description</th>
</tr>
</thead>
<tbody>
<tr align="left" valign="top">
<td align="left" id="r2c1-t8" headers="r1c1-t8">
<p>Role Ref Name</p>
</td>
<td align="left" headers="r2c1-t8 r1c2-t8">Specifies the security role reference's display name. 
<object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer">
<param name="content" value="http://www.oracle.com/pls/topic/lookup?ctx=nb8200&id=NBDAG114">
<param name="text" value="<html><u>How?</u></html>">
<param name="textFontSize" value="medium">
<param name="textColor" value="blue">
</object>
</td>
</tr>
<tr align="left" valign="top">
<td align="left" id="r3c1-t8" headers="r1c1-t8">
<p>Role Ref Link</p>
</td>
<td align="left" headers="r3c1-t8 r1c2-t8">Specifies the security role defined in the Security Roles table in the Security section of the visual editor.</td>
</tr>
<tr align="left" valign="top">
<td align="left" id="r4c1-t8" headers="r1c1-t8">
<p>Description</p>
</td>
<td align="left" headers="r4c1-t8 r1c2-t8">Specifies a description.</td>
</tr>
<tr align="left" valign="top">
<td align="left" id="r5c1-t8" headers="r1c1-t8">
<p>Run As</p>
</td>
<td align="left" headers="r5c1-t8 r1c2-t8">Specifies the run-as element for the security roles.</td>
</tr>
</tbody>
</table>
<br />
<!-- -->
<p>Note that when you click <b>Remove</b> at the top of the Servlets section, you remove the definitions for the servlet or JSP file from the <code dir="ltr">web.xml</code> file, but you do not remove the servlet or JSP file itself. To delete the servlet or JSP file, right-click it in the Projects window and choose <b>Delete</b>.</p>
<a id="NBCSH3799" name="NBCSH3799"></a>
<hr><p><b>Related Topics</b></p>
<p><i>Developing Applications with NetBeans IDE</i>, 
<object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer">
<param name="content" value="http://www.oracle.com/pls/topic/lookup?ctx=nb8200&id=NBDAG1091">
<param name="text" value="<html><u>&quot;Working with Servlets&quot;</u></html>">
<param name="textFontSize" value="medium">
<param name="textColor" value="blue">
</object>
</p>
<p><i>Developing Applications with NetBeans IDE</i>, 
<object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer">
<param name="content" value="http://www.oracle.com/pls/topic/lookup?ctx=nb8200&id=NBDAG2812">
<param name="text" value="<html><u>&quot;About Deployment Descriptors&quot;</u></html>">
<param name="textFontSize" value="medium">
<param name="textColor" value="blue">
</object>
</p>
<p><i>Developing Applications with NetBeans IDE</i>, 
<object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer">
<param name="content" value="http://www.oracle.com/pls/topic/lookup?ctx=nb8200&id=NBDAG1111">
<param name="text" value="<html><u>&quot;Configuring a Web Application&quot;</u></html>">
<param name="textFontSize" value="medium">
<param name="textColor" value="blue">
</object>
</p>

<!-- -->
<!-- Start Footer -->


<table summary="" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td align="left" width="86%"><a href="legal_notice.htm">
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements; and to You under the Apache License, Version 2.0.</a>
</td>
</tr>
</table>
<!-- -->
</body>
</html>
